﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sunboxsoft.ASMS.Client.Domain.WebRef
{
    public partial class EMaintenanceBillMaterial
    {
        /// <summary>
        /// 商品名称
        /// </summary>
        public string MaterialName { get; private set; }

        /// <summary>
        /// 总金额
        /// </summary>
        public decimal ActualAmount
        {
            get
            {
                return Math.Round(this.Price * this.Count * this.Discount, 2);
            }
        }

        /// <summary>
        /// 销售提成金额（文本)
        /// </summary>
        public string SalesCommissionAmountText
        {
            get
            {
                if (this.SalesCommissionType != null
                    && this.SalesCommission != null)
                {
                    if (this.SalesCommissionType.Value == Constant.CommissionTypes.Fixed)
                    {
                        return string.Format("{0:N}", this.SalesCommission.Value);
                    }
                    else if (this.SalesCommissionType.Value == Constant.CommissionTypes.Rate)
                    {
                        return string.Format("{0:N}", this.Price * this.Count * this.Discount * this.SalesCommission.Value, 2);
                    }
                }
                return "0";
            }
        }

        /// <summary>
        /// 销售提成类型(文字)
        /// </summary>
        public string SalesCommissionTypeText
        {
            get
            {
                if (this.SalesCommissionType.Value == Constant.CommissionTypes.Fixed)
                {
                    return Constant.CommissionTypes.FixedItem.Text;
                }
                else if (this.SalesCommissionType.Value == Constant.CommissionTypes.Rate)
                {
                    return Constant.CommissionTypes.RateItem.Text;
                }
                else if (this.SalesCommissionType.Value == Constant.CommissionTypes.None)
                {
                    return Constant.CommissionTypes.NoneItem.Text;
                }
                else
                {
                    return "没提成";
                }
            }
        }

        public EMaintenanceBillMaterial()
        {
        }

        public EMaintenanceBillMaterial(string materialName)
        {
            MaterialName = materialName;
        }
    }
}
